package org.jsrml.sv.mob.controller.base;

import java.util.List;
import javax.servlet.http.HttpServletRequest;

import org.jsrml.common.util.JSONResultDTO;
import org.jsrml.core.base.entity.Area;
import org.jsrml.core.base.entity.City;
import org.jsrml.core.base.entity.Province;
import org.jsrml.core.base.qo.AreaQO;
import org.jsrml.core.base.qo.CityQO;
import org.jsrml.core.base.qo.ProvinceQO;
import org.jsrml.core.base.service.AreaService;
import org.jsrml.core.base.service.CityService;
import org.jsrml.core.base.service.ProvinceService;
import org.jsrml.sv.mob.controller.BaseController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/address")
public class AddressController extends BaseController {

	private static Logger logger = LoggerFactory.getLogger(AddressController.class);

	@Autowired
	private ProvinceService provinceService;
	
	@Autowired
	private CityService cityService;
	
	@Autowired
	private AreaService areaService;

	/**
	 * 省份查询
	 * 
	 * @return
	 */
	@RequestMapping("/province/query_list")
	@ResponseBody
	public JSONResultDTO queryProvinceList(HttpServletRequest request, @RequestBody ProvinceQO qo) {
		List<Province> provinces = provinceService.queryList(qo);
		return createSuccessResult(provinces);
	}

	/**
	 * 城市查询
	 * 
	 * @return
	 */
	@RequestMapping("/city/query_list")
	@ResponseBody
	public JSONResultDTO queryCityList(HttpServletRequest request, @RequestBody CityQO qo) {
		List<City> cities = cityService.queryList(qo);
		return createSuccessResult(cities);
	}

	/**
	 * 地区查询
	 * 
	 * @return
	 */
	@RequestMapping("/area/query_list")
	@ResponseBody
	public JSONResultDTO queryAreaList(HttpServletRequest request, @RequestBody AreaQO qo) {
		List<Area> cities = areaService.queryList(qo);
		return createSuccessResult(cities);
	}

}
